<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <artifactId>camunda-qa-tomcat-runtime</artifactId>
  <packaging>pom</packaging>

  <name>Camunda Platform - QA Tomcat Test Runtime</name>

  <parent>
    <groupId>org.camunda.bpm.qa</groupId>
    <artifactId>camunda-qa</artifactId>
    <version>7.20.0-SNAPSHOT</version>
  </parent>

  <dependencies>
    <dependency>
      <!--
        Make sure it comes after assembly in the build.
        Leave scope test, otherwise libs from pom will be copied into Tomcat's lib folder
      -->
      <groupId>org.camunda.bpm.tomcat</groupId>
      <artifactId>camunda-tomcat-assembly</artifactId>
      <version>${project.version}</version>
      <type>pom</type>
      <scope>test</scope>
    </dependency>

    <!--
      database drivers
      we deploy all and only activate one through server.xml
    -->
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>org.python</groupId>
      <artifactId>jython</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.jruby</groupId>
      <artifactId>jruby-complete</artifactId>
      <scope>runtime</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm.qa</groupId>
      <artifactId>camunda-qa-ensure-clean-db</artifactId>
      <version>${project.version}</version>
      <scope>runtime</scope>
    </dependency>

  </dependencies>

  <profiles>
    <profile>
      <id>tomcat</id>
      <build>
        <resources>
          <resource>
            <directory>src/main</directory>
            <filtering>true</filtering>
          </resource>
        </resources>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-server</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <inherited>false</inherited>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.camunda.bpm.tomcat</groupId>
                      <artifactId>camunda-tomcat-assembly</artifactId>
                      <version>${project.version}</version>
                      <type>tar.gz</type>
                      <overWrite>true</overWrite>
                      <outputDirectory>target/</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
              <execution>
                <id>copy-libs</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <inherited>false</inherited>
                <configuration>
                  <includeScope>runtime</includeScope>
                  <outputDirectory>target/server/apache-tomcat-${version.tomcat}/lib</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!-- copy filtered configuration resources -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <configuration>
              <delimiters>
                <delimiter>${*}</delimiter>
              </delimiters>
              <useDefaultDelimiters>false</useDefaultDelimiters>
            </configuration>
            <executions>
              <execution>
                <id>copy-resources</id>
                <phase>generate-test-resources</phase>
                <goals>
                  <goal>resources</goal>
                </goals>
                <configuration>
                  <overwrite>true</overwrite>
                  <outputDirectory>target/server/apache-tomcat-${version.tomcat}</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
